#pragma once

#include <butil/logging.h>
#include <brpc/server.h>
#include "frpc.pb.h"
#include <frpc/auth.h>
#include "user_svc.h"
#include "static_data_svc.h"
#include "public_svc.h"
#include "admin_svc.h"
namespace frpcType{
  static  int run(int port){
        // Generally you only need one Server.
    brpc::Server server;

    UserServiceImpl user_svc;
    if (server.AddService(&user_svc, 
                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
        LOG(ERROR) << "Fail to add service";
        return -1;
    }
    
      StaticDataSvcImpl staticdata_svc;
    if (server.AddService(&staticdata_svc, 
                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
        LOG(ERROR) << "Fail to add service";
        return -1;
    }
          PublicServiceImpl public_svc;
    if (server.AddService(&public_svc, 
                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
        LOG(ERROR) << "Fail to add service";
        return -1;
    }
              AdminSvcImpl admin_svc;
    if (server.AddService(&admin_svc, 
                          brpc::SERVER_DOESNT_OWN_SERVICE) != 0) {
        LOG(ERROR) << "Fail to add service";
        return -1;
    }
    // Start the server.
    brpc::ServerOptions options;
    options.idle_timeout_sec = -1;
    frpc::Auth auth;
    //options.auth=&auth;
    if (server.Start(port, &options) != 0) {
        LOG(ERROR) << "Fail to start EchoServer";
        return -1;
    }
    server.RunUntilAskedToQuit();
    return 0;
    }

}